<link rel='stylesheet' href='${rc.getContextPath()}/manage/styles/colorPicker/spectrum.css' />
<style>
dl.defectLookup span.error
{
    position:absolute !important;
    left:257px;
}

.sp-dd {
    background: url("${rc.getContextPath()}/manage/styles/dwz/themes/default/images/button/imgX.png");
    background-position: -163px -1px;
    height: 18px;
    width: 16px;
    position: absolute;
    right: 0px;
    top: 0px;
    border: 1px solid #D9DFE5;
}

.sp-replacer {
    padding: 0px;
    border: 0px !important;
    background: #EDF4F5 none repeat scroll 0% 0%;
    width: 146px;
    height: 24px;
    position: relative;
}

.sp-replacer.sp-active {
    border-color: #289BE5;
}

.sp-container, .sp-palette-container {
    border-color: #BDD7E7;
}

.sp-input {
    border: 1px solid #D9DFE5;
}

.sp-preview {
    width: 127px;
    height: 22px;
    border: 1px solid #D9DFE5;
    margin: 0px;
}
</style>
<div class="pageContent">
    <form method="post"
        action="${rc.getContextPath()}/manage/defect/saveDefect"
        class="pageForm required-validate"
        onsubmit="return defectCallBack(this,dialogAjaxDone);">
        <div class="pageFormContent" >
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (defect.defectText)??>${defect.defectCode!''}</#if>">
            <fieldset>
                <dl>
                    <dt><@label key="defectCode.C,colon">缺陷编号：</@label></dt>
                    <dd>
                        <input name="defectCode" value="<#if (defect.defectCode)??>${defect.defectCode!''}</#if>" 
                              size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='defectCode.C,alreadyExists'>缺陷编号已存在</@label>"
                              readonly="readonly"
                        />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectText.C,colon">缺陷描述：</@label></dt>
                    <dd>
                        <input name="defectText"
                            value="<#if (defect.defectText)??>${defect.defectText!''}</#if>"
                            size="22" type="text" maxlength="60" class="required" readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="defectLevelCode.C,colon">缺陷等级编号：</@label></dt>
                    <dd>
                        <input class="required" id="defectLevelLookup.defectLevelCode" name="defectLevelCode" value="${defect.defectLevelCode!''}" type="text" readonly="readonly"/>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectLevelText.C,colon">缺陷等级描述：</@label></dt>
                    <dd>
                        <input name="defectLevelText" id="defectLevelLookup.defectLevelText"
                            value="<#if (defect.defectLevelText)??>${defect.defectLevelText!''}</#if>"
                            size="22" type="text" maxlength="60" readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="responsibilityTypeCode.C,colon">责任类型编号：</@label></dt>
                     <dd>
                        <input class="required" id="responsibilityTypeLookup.responsibilityTypeCode" name="responsibilityTypeCode" value="${defect.responsibilityTypeCode!''}" type="text" readonly="readonly"/>
                    </dd> 
                </dl>
                <dl>
                    <dt><@label key="responsibilityTypeText.C,colon">责任类型描述：</@label></dt>
                    <dd>
                        <input name="responsibilityTypeText" id="responsibilityTypeLookup.responsibilityTypeText"
                            value="<#if (defect.responsibilityTypeText)??>${defect.responsibilityTypeText!''}</#if>"
                            size="22" type="text" maxlength="60"  readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="defectTypeCode.C,colon">缺陷类型编号：</@label></dt>
                    <dd>
                        <input class="required" id="defectTypeLookup.defectTypeCode" name="defectTypeCode" value="${defect.defectTypeCode!''}" type="text" readonly="readonly"/>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectTypeText.C,colon">缺陷类型描述：</@label></dt>
                    <dd>
                        <input name="defectTypeText" id="defectTypeLookup.defectTypeText"
                            value="<#if (defect.defectTypeText)??>${defect.defectTypeText!''}</#if>"
                            size="22" type="text" maxlength="60"  readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="repairmethodCode.C,colon">返修方法代码：</@label></dt>
                    <dd>
                        <input class="required" id="repairmethodLookup.repairmethodCode" name="repairmethodCode" value="${defect.repairmethodCode!''}" type="text" readonly="readonly" />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="repairmethodText.C,colon">返修方法描述：</@label></dt>
                    <dd><input id="repairmethodLookup.repairmethodText" value="<#if (defect.repairmethodCode)??>${defect.repairmethodCode!''}</#if>" readonly="readonly" size="22" type="text" maxlength="60" type="text" name="repairmethodText" /></dd>
                </dl>
                
                <dl style="height:40px;">
                    <dt><@label key="">背景色：</@label></dt>
                    <dd><input type='text' id="colorPicker" name="backgroundColor" value="${defect.backgroundColor!'#FF0000'}"/></dd>
                </dl>
                
                <dl style="height:40px;">
                    <dd>
                        <label><input type="checkbox" name="lockFlag" value="1" disabled="disabled"
                            <#if
                            (defect.pictureFlag)?? && (defect.pictureFlag == 1)>
                            checked="true"</#if>><@label key="pictureFlag.C">图形采集标志</@label></label>
                            
                            <label><input type="checkbox" name="lockFlag" value="1"
                            disabled="disabled"
                            <#if
                            (defect.lockFlag)?? && (defect.lockFlag == 1)>
                            checked="true"</#if>><@label key="lockFlag.C">锁定标记</@label></label>
                    </dd>
                </dl>
            </fieldset>
            
            <div style="height:130px;width:620px;border:1px solid #d8dfe5;overflow-y:auto;">
            <#if defectAttribute??&&(defectAttribute?size>0)>
                <#list defectAttribute as attribute>
                
                         <#if attribute.requiredFlag==1>
                            <#assign required="required">
                         <#else>
                             <#assign required="">
                         </#if>
                         
                    
                    <dl>
                        <dt>${attribute.attributeText!''}<@label key="colon">：</@label></dt>
                        <dd>
                        <input type='hidden' name="defectAttributeValue[${attribute_index}].attributeCode" value="${attribute.attributeCode!''}" />
                        <#if attribute.valueTypeECode=="enum">
                            <select name="defectAttributeValue[${attribute_index}].attributeValue" 
                                    class="${required!''}" disabled="disabled">
                                    <option value=""><@label key="selected_first.C">请选择：</@label></option>
                                <#list attribute.attributeEnum as attributeEnum>
                                    <option value="${attributeEnum.attributeValue!''}"
                                        <#if attributeEnum.attributeValue==attribute.attributeValue>
                                            selected="selected"
                                        </#if>
                                    >${attributeEnum.attributeValue!''}</option>
                                </#list>
                            </select>
                        <#elseif attribute.valueTypeECode=="date">
                                <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text' dateFmt="yyyy-MM-dd" 
                                class="${required!''}" value="${attribute.attributeValue!''}" readonly="readonly" />
                                
                        <#elseif attribute.valueTypeECode=="number">
                                <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text' 
                                    class="${required!''} number" value="${attribute.attributeValue!''}" readonly="readonly"/>
                        <#else>
                                 <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text'
                                    class="${required!''}"  value="${attribute.attributeValue!''}" readonly="readonly"/> 
                        </#if>
                        </dd>
                    </dl>
                </#list>
            </#if>            
            </div>
        </div>
        <#if defect??>
            <#assign createInfo=defect>
            <div style="padding: 0px 10px 10px 10px;">
                <div class="createInfo" style="width:600px;">
                    <p>
                        <label class="user"><@label key="createUser.C,colon">创建人：</@label><#if (createInfo.createUser)??>${createInfo.createUser}</#if></label> <label class="time"><@label key="createDateTime.C,colon">创建时间：</@label><#if (createInfo.createDateTime)??>${createInfo.createDateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></label>
                    </p>
                    <p>
                        <label class="user"><@label key="modifyUser.C,colon">修改人：</@label><#if (createInfo.modifyUser)??>${createInfo.modifyUser}</#if></label> <label class="time"><@label key="modifyDateTime.C,colon">修改时间</@label><#if (createInfo.modifyDateTime)??>${createInfo.modifyDateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></label>
                    </p>
                </div>
            </div>
        </#if>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                                <button type="button" class="close" onclick="beforeClose();"><@label key="close.B">关闭</@label></button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script>
$(function(){
    var dialog= $.pdialog.getCurrent();
    var colorPicker=$("#colorPicker", dialog);
    var colorVal=colorPicker.val();
    var colorOption={
            color: colorVal,
            chooseText: "<@label key='select.C'>选择</@label>",
            cancelText: "<@label key='cancel.B'>取消</@label>",
            showInput: true,
            preferredFormat: "hex",
            showInput: true,
            showPalette: true,
            disabled:true,
            palette: [
                ["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
                ["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
                ["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
                ["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
                ["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
                ["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
                ["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
                ["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]
            ]
        };
    if(!colorPicker.spectrum){
        var ctx='${rc.getContextPath()}';
        $.getScript(ctx+'/styles/colorPicker/spectrum.js',function(){
            //初始化颜色选择器
            colorPicker.spectrum(colorOption);
        });
    }
    else
    {
        colorPicker.spectrum(colorOption);
    }
    $('.sp-dd', dialog).empty();
});
</script>
